﻿using KingRoad.EPM.DeviceDAL.BllRoadwayService;
using KingRoad.EPM.DeviceEntity.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Unis.Framework.Core.Utility;

namespace KingRoad.EPM.DeviceBLL.UIRules
{
    public class BllRoadwayUIRule
    {
        private readonly IBllRoadwayService _bllRoadwayService;


        public BllRoadwayUIRule() { }

        /// <summary> 
        /// construct function... 
        /// </summary> 
        public BllRoadwayUIRule(IBllRoadwayService bllRoadwayService)
        {
            _bllRoadwayService = bllRoadwayService;
        }

        /// <summary>
        /// 根据条件获取信息
        /// </summary>
        /// <returns></returns>
        public List<BllRoadwayInfo> GetEntityListBySql(string sql)
        {
            var ret = _bllRoadwayService.GetEntityList(sql);
            return ret;
        }
        /// <summary>
        /// 根据条件分页查询信息
        /// </summary>
        /// <param name="numCurrentPage">当前页</param>
        /// <param name="numPerPage">每页数据大小</param>
        /// <param name="orderByField">排序字段名称</param>
        /// <param name="totalRecord">总数据量</param>
        /// <param name="sqlCondition">sql查询条件</param>
        /// <param name="desc">排序方式</param>
        /// <param name="table">表名</param>
        /// <returns></returns>
        public List<BllRoadwayInfo> GetEntityListByContionRe(int numCurrentPage, int numPerPage,
                                                                        string orderByField, out int totalRecord, string sqlCondition, string desc, string table)
        {
            var list = _bllRoadwayService.GetRoadwayEntityListByContionRe(numCurrentPage, numPerPage, orderByField, out totalRecord, sqlCondition, desc, table);
            return list;
        }
        /// <summary>
        /// 查看
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public BllRoadwayInfo GetEntityById(int id)
        {
            var ret = _bllRoadwayService.GetEntityById(id);
            return ret;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool InsertEntity(BllRoadwayInfo entity)
        {
            var ret = _bllRoadwayService.InsertEntity(entity);
            return ret > 0;
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool UpdateEntity(BllRoadwayInfo entity)
        {
            var ret = _bllRoadwayService.UpdateEntity(entity);
            return ret > 0;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool DeleteEntity(int id)
        {
            var ret = _bllRoadwayService.DeleteEntity(id);
            return ret > 0;
        }

        /// <summary>
        /// //根据收费站ID查询设备状态统计显示在地图上
        /// </summary>
        /// <returns></returns>
        public DataTable GetMeterStateTotalBySql(string sql)
        {
            var ret = _bllRoadwayService.GetMeterStateTotalBySql(sql);
            return ret;
        }
    }
}
